<%@page import="cn.yi.newsys.pojo.NewsCategory"%>
<%@page import="cn.yi.newsys.service.impl.NewsCategoryServiceImpl"%>
<%@page import="cn.yi.newsys.service.NewsCategoryService"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'themeAdd.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>
    <%
    	request.setCharacterEncoding("UTF-8");
    	String name = request.getParameter("themeName") ;
    	// 创建新闻主题业务逻辑对象
    	NewsCategoryService ncs = new NewsCategoryServiceImpl() ;
    	// 创建新闻主题对象
    	NewsCategory nc = new NewsCategory() ;
    	nc.setName(name);
    	int num = ncs.addNewsCategory(nc) ;
    	if(num == -1){
    		out.println("<script>alert('存在同名主题！');location.href='manage/index.jsp';</script>");
    	}else if( num == 0 ){
    		out.println("<script>alert('出现未知故障，添加失败！');location.href='manage/index.jsp';</script>");
    	}else{
    		out.println("<script>alert('添加成功！');location.href='manage/index.jsp';</script>");
    	}
     %>
  </body>
</html>
